//引入experss模块
const express = require('express');
//引入连接池
const pool = require('../pool');
//创建轮播图路由器
const home = express.Router();
//创建轮播图的接口
home.get('/home',(req,res)=>{
  let sql ='select lunboid,lunbophoto from tykyo_lunbo order by lunboid';
  //执行SQL语句
  pool.query(sql,(error,lunbo)=>{
    if(error) throw error;
    pool.query('select hid,htitle from tykyo_head',(err,head)=>{
      if(err) throw err;
      pool.query('select jiangpaiid,country,gold,silver,bronze,total,count,countryhead from tykyo_jiangpai order by jiangpaiid',(err,jiangpai)=>{
        if(err) throw err;
        pool.query('select runid,runitem,runphoto from tykyo_run order by runid',(err,run)=>{
          if(err) throw err;
          pool.query('select runerid,runerphoto,runername from tykyo_runer order by runerid',(err,runer)=>{
            if(err) throw err;
            res.send({message:'ok',code:200,lunbo:lunbo,head:head,jiangpai:jiangpai,run:run,runer:runer})
          })
        })
      })
    })
  });
});
module.exports=home;